package cn.itcast.bos.mq;

import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Component;

@Component
public class SmsConsumer implements MessageListener {

	@Override
	public void onMessage(Message message) {
		MapMessage mapMessage = (MapMessage) message;
		try {
			/*
			 * String result =
			 * SmsUtils.sendSmsByHTTP(mapMessage.getString("telephone"),
			 * mapMessage.getString("msg"));
			 */
			String result = "000/x";
			if (result.startsWith("000")) {
				System.out.println(
						"发送短信的手机号是：" + mapMessage.getString("telephone") + 
						"短信内容是：" + mapMessage.getString("msg"));
			}else{
				throw new RuntimeException("短信验证码错误，信息码是："+result);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
